package com.fjh.springboot_01.service.impl;

import com.fjh.springboot_01.pojo.homework.MistakeBook;
import com.fjh.springboot_01.mapper.MistakeBookMapper;
import com.fjh.springboot_01.service.MistakeBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;

@Service
public class MistakeBookServiceImpl implements MistakeBookService {
    @Autowired
    private MistakeBookMapper mistakeBookMapper;

    @Override
    public void addMistake(MistakeBook mistakeBook) {
        mistakeBookMapper.insert(mistakeBook);
    }

    @Override
    public List<MistakeBook> getStudentMistakes(Integer studentId) {
        return mistakeBookMapper.findByStudentId(studentId);
    }

    @Override
    public void updateMistake(MistakeBook mistakeBook) {
        mistakeBookMapper.update(mistakeBook);
    }

    @Override
    public MistakeBook findByStudentAndQuestion(Integer studentId, Integer questionId) {
        return mistakeBookMapper.findByStudentAndQuestion(studentId, questionId);
    }

    @Override
    public void deleteMistake(Integer mistakeId) {
        mistakeBookMapper.delete(mistakeId);
    }

    @Override
    public void updateRetryCount(Integer mistakeId, boolean isCorrect) {
        mistakeBookMapper.updateRetryCount(mistakeId, isCorrect);
    }

    @Override
    public List<Map<String, Object>> getKnowledgeStats(Integer studentId) {
        return mistakeBookMapper.findKnowledgeStats(studentId);
    }
} 